﻿using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace CurrentItemPropertiesWebPart.VisualWebPart1
{
    [ToolboxItemAttribute(false)]
    public class CurrentItemPropertiesVisualWebPart : WebPart
    {
        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/CurrentItemPropertiesWebPart/CurrentItemPropertiesVisualWebPart/CurrentItemPropertiesUserControl.ascx";

        [WebBrowsable(true),
         WebDisplayName("Style Library URL"),
         WebDescription("Site Collection related URL of the style library"),
         Personalizable(PersonalizationScope.Shared),
         Category("Settings"),
         DefaultValue("/VG Styles")]
        public string StyleLibraryUrl
        {
            get;
            set;
        }

        [WebBrowsable(true),
         WebDisplayName("Stylesheet File Name"),
         WebDescription("Name of the stylesheet file name"),
         Personalizable(PersonalizationScope.Shared),
         Category("Settings"),
         DefaultValue("WS.CurrentItemProperties.xslt")]
        public string StyleFileName
        {
            get;
            set;
        }

        protected override void CreateChildControls()
        {
            CurrentItemPropertiesUserControl control = Page.LoadControl(_ascxPath) as CurrentItemPropertiesUserControl;
            if (control != null)
            {
                control.WebPart = this;
            }
            Controls.Add(control);
        }

        public CurrentItemPropertiesVisualWebPart()
        {
            this.AllowMinimize = false;
            this.AllowHide = false;
            this.AllowClose = false;
            this.ChromeType = PartChromeType.None;
        }
    }
}
